home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
util
/
cdity
/
ModeProSrc.lha
/
Prefs
/
MPP_ProcessInput.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-25
|
20KB
|
806 lines
#include "mppexterns.h"
void ProcessInput(void)
{
struct IntuiMessage *imsg;
ULONG winsig, signal, prefsig, allsigs,replysig,forcedsig;
forcedsig=1 << ForcedSig;
replysig= 1 << ReplyPort->mp_SigBit;
prefsig = 1 << PrefsPort->mp_SigBit;
winsig = 1 << Win->UserPort->mp_SigBit;
allsigs = replysig | winsig | prefsig | SIGBREAKF_CTRL_C | forcedsig;
while (!ClosePrefs || MsgsOut)
{
signal=Wait(allsigs);
if(forcedsig & signal)
{
if(!ForcedEditMsg)
{
if(ForcedEditMsg=(struct MPMessage *)GetMsg(&MPSem->PrefsToDoPort));// (4.62.8)
RemakeGads();
}
}
if(replysig & signal)
{
struct MPMessage *mpm;
while(mpm=(struct MPMessage *)GetMsg(ReplyPort))
{
//printf("Freeing Replied Msg %8x\n",mpm);
FreeVec(mpm);
MsgsOut--;
}
}
if(SIGBREAKF_CTRL_C & signal)
ClosePrefs=TRUE;
if(winsig & signal)
{
while(imsg = GT_GetIMsg(Win->UserPort))
{
switch (imsg->Class)
{
case IDCMP_NEWSIZE:
if(!RemakeGads())
{
ClosePrefs=TRUE;
}
break;
case IDCMP_MOUSEMOVE:
process_mousemoves(imsg);
break;
case IDCMP_GADGETUP:
process_gadgetups(imsg);
break;
case IDCMP_VANILLAKEY:
Process_Keys(imsg);
break;
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh(Win);
RefreshGUI();
GT_EndRefresh(Win,TRUE);
break;
case IDCMP_MENUPICK:
process_menus(imsg);
break;
}
GT_ReplyIMsg(imsg);
}
{
struct DefaultNode *n;
if(n=GetActiveNode())
{
switch(ActivateStrGad)
{
/*****************************************************************************
case GD_NAME:
if(CurrentList==PL_SCREENMODES)
ActivateStrGad=0;
break;
******************************************************************************/
case GD_WIDTH:
case GD_HEIGHT:
if(n->ModeSelect!=MS_PROMOTE_SCREENMODE && n->ModeSelect!=MS_PROMOTE_REQUESTER)
ActivateStrGad=0;
break;
case GD_PENVAL:
if(!n->Look3D)
ActivateStrGad=0;
break;
case GD_LOCKEDPENS:
if(!(n->Flags & SHAREPENS))
ActivateStrGad=0;
break;
case GD_PUBNAME:
if(n->PubOptions==0)
ActivateStrGad=0;
break;
case GD_HOTKEYSTR:
if(!(n->Flags & SCRHOTKEY))
ActivateStrGad=0;
break;
}
}
else
ActivateStrGad=0;
}
if(ActivateStrGad)
{
ActivateGadget(LG_GetGadget(GadControl,ActivateStrGad),Win,NULL);
ActivateStrGad=0;
}
}
if(prefsig & signal)
ProcessPrefsMessages();
}
}
void process_gadgetups(struct IntuiMessage *imsg)
{
struct Gadget *gad;
struct DefaultNode *n;
UWORD code,id;
code=imsg->Code;
gad=(struct Gadget*)imsg->IAddress;
id=gad->GadgetID;
switch(id)
{
case GD_NEW:
GD_New();
break;
case GD_SAVE:
GD_Save();
break;
case GD_USE:
GD_Use();
break;
case GD_CANCEL:
GD_Cancel();
break;
case GD_TYPE:
GD_Type(code);
break;
case GD_FE_CANCEL:
GD_FE_Cancel();
break;
case GD_FE_NEVER:
GD_FE_Never();
break;
case GD_FE_USEDELETE:
GD_FE_UseDelete();
break;
case GD_FE_SAVEUSE:
GD_FE_SaveUse();
break;
}
if(n=GetActiveNode())
switch(id)
{
case GD_LIST:
GD_List(code,0,imsg);
break;
case GD_SELECT_NAME:
GD_SelectName(n);
break;
case GD_NAME:
LG_SetGadgetAttrs(GadControl,GD_LIST,
GTLV_Labels,~0,TAG_DONE);
if(GetGadString(LG_GetGadget(GadControl,GD_NAME)))
{
STRPTR oldname;
ObtainSemaphore(&MPSem->NodeSem);
oldname=n->Def_Node.ln_Name;
if(n->Def_Node.ln_Name=AllocVec( 1+strlen(GetGadString(LG_GetGadget(GadControl,GD_NAME))),MEMF_CLEAR|MEMF_PUBLIC))
{
/***************************************************************************************************************************/
n->OrigDisplayID=INVALID_ID;
/***************************************************************************************************************************/
strcpy(n->Def_Node.ln_Name,GetGadString(LG_GetGadget(GadControl,GD_NAME)));
FreeVec(oldname);
}
else
{
//Remove((struct Node *)n);
//FreeDNode(n);
n->Def_Node.ln_Name=oldname;
// UpdateGadgets();
}
ReleaseSemaphore(&MPSem->NodeSem);
}
LG_SetGadgetAttrs(GadControl,GD_LIST,
GTLV_Labels,&MPSem->PromotionList[CurrentList],
TAG_DONE);
if(imsg->Qualifier&3)
{//shifted
switch(code)
{
case CURSORUP:
//GD_Move((NodeCnt-LVActive-1)+1);
GD_Move(-1,TRUE);
LG_SetGadgetAttrs(GadControl,GD_MOVE,
GTSL_Level, (NodeCnt-1)-LVActive,
TAG_DONE);
ActivateStrGad=GD_NAME;
break;
case CURSORDOWN:
//GD_Move((NodeCnt-LVActive-1)-1);
GD_Move(1,TRUE);
LG_SetGadgetAttrs(GadControl,GD_MOVE,
GTSL_Level, (NodeCnt-1)-LVActive,
TAG_DONE);
ActivateStrGad=GD_NAME;
break;
}
}
else
{
switch(code)
{
case CURSORUP:
LVActive-=2;
case CURSORDOWN:
LVActive++;
GD_List(LVActive,0,0);
LG_SetGadgetAttrs(GadControl,GD_LIST,
GTLV_Selected ,LVActive,
TAG_DONE);
break;
}
}
break;
case GD_MODESEL:
GD_ModeSel(n,code,0);
break;
case GD_SELMODE:
GD_SelMode(n);
break;
case GD_WIDTH:
n->Width=GetGadNumber(gad);
break;
case GD_HEIGHT:
n->Height=GetGadNumber(gad);
break;
case GD_OVERSCAN:
GD_Overscan(n,code,FALSE);
break;
case GD_REMOVE:
GD_Remove(n);
break;
case GD_LOOK3D:
GD_Look3D(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_AUTOSCROLL:
GD_AutoScroll(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_3D_DEFAULT:
GD_3D_Default(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_PENLIST:
GD_PenList(n,code,0);
break;
case GD_PENVAL:
n->Pens[ActivePen]=GetGadNumber(LG_GetGadget(GadControl,GD_PENVAL));
switch(code)
{
case CURSORUP:
ActivateStrGad=GD_PENVAL;
ActivePen--;
if(ActivePen<0)
ActivePen=NumDriPens-1;
break;
case CURSORDOWN:
ActivateStrGad=GD_PENVAL;
ActivePen++;
if(ActivePen>=NumDriPens)
ActivePen=0;
break;
}
// if(imsg->Qualifier&3)
SetPenValues(n->Pens);
break;
case GD_RESETPENS:
GD_ResetPens(n);
break;
case GD_PICKFONT:
GD_PickFont(n);
break;
case GD_INTERLEAVE:
GD_Interleave(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_BEHIND:
GD_Behind(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_BLANK_BORDER:
GD_Blank_Border(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_CENTER:
n->CenterFlags=code;
break;
case GD_FASPECT:
GD_FAspect(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_SFONT:
GD_SFont(n,code,0);
break;
case GD_PUBOPT:
GD_PubOpt(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_PUBNAME:
ReplaceGStr(&n->PubName,GD_PUBNAME);
/*
if(GetGadString(LG_GetGadget(GadControl,GD_PUBNAME)))
{
ObtainSemaphore(&MPSem->NodeSem);
FreeVec(n->PubName);
if(n->PubName=AllocVec( 1+strlen(GetGadString(LG_GetGadget(GadControl,GD_PUBNAME))),MEMF_CLEAR|MEMF_PUBLIC))
strcpy(n->PubName,GetGadString(LG_GetGadget(GadControl,GD_PUBNAME)));
ReleaseSemaphore(&MPSem->NodeSem);
} */
break;
case GD_DODEPTH:
GD_DoDepth(n,gad->Flags & GFLG_SELECTED,0);
break;
case GD_SHAREPENS:
GD_SharePens(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_LOCKEDPENS:
ReplaceGStr(&n->LockedPens,GD_LOCKEDPENS);
/* if(GetGadString(LG_GetGadget(GadControl,GD_LOCKEDPENS)))
{
ObtainSemaphore(&MPSem->NodeSem);
FreeVec(n->LockedPens);
if(n->LockedPens=AllocVec( 1+strlen(GetGadString(LG_GetGadget(GadControl,GD_LOCKEDPENS))),MEMF_CLEAR|MEMF_PUBLIC))
strcpy(n->LockedPens,GetGadString(LG_GetGadget(GadControl,GD_LOCKEDPENS)));
ReleaseSemaphore(&MPSem->NodeSem);
} */
break;
case GD_HOTKEYOPT:
GD_HotKeyOpt(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_HOTKEYSTR:
ReplaceGStr(&n->HotKey,GD_HOTKEYSTR);
/* if(GetGadString(LG_GetGadget(GadControl,GD_HOTKEYSTR)))
{
ObtainSemaphore(&MPSem->NodeSem);
FreeVec(n->HotKey);
if(n->HotKey=AllocVec( 1+strlen(GetGadString(LG_GetGadget(GadControl,GD_HOTKEYSTR))),MEMF_CLEAR|MEMF_PUBLIC))
strcpy(n->HotKey,GetGadString(LG_GetGadget(GadControl,GD_HOTKEYSTR)));
ReleaseSemaphore(&MPSem->NodeSem);
}*/
break;
case GD_PALETTE:
GD_Palette(n,gad->Flags & GFLG_SELECTED,0);
break;
case GD_EDITPALETTE:
GD_EditPalette(n);
break;
case GD_FORCE_PLANAR:
GD_Force_Planar(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_BACKDROPOPT:
// GD_BackdropOpt(n,gad->Flags & GFLG_SELECTED,FALSE);
GD_BackdropOpt(n,code,FALSE);
break;
case GD_BACKDROPCENTER:
GD_BackdropCenter(n,gad->Flags & GFLG_SELECTED,FALSE);
break;
case GD_BACKDROPPICK:
GD_BackdropPick(n);
break;
case GD_BACKDROPCOLOR:
GD_BackdropColor(n,FALSE);
break;
} /* End Switch */
}
void ReplaceGStr(STRPTR *A, ULONG GID)
{
STRPTR str;
if(str=GetGadString(LG_GetGadget(GadControl,GID)))
{
ObtainSemaphore(&MPSem->NodeSem);
FreeVec(*A);
if(*A=AllocVec( 1+strlen(str),MEMF_CLEAR|MEMF_PUBLIC))
{
strcpy(*A,str);
}
ReleaseSemaphore(&MPSem->NodeSem);
}
}
void Process_Keys(struct IntuiMessage *IMsg)
{
ULONG code,gadid;
WORD dirchange=1;
WORD letter;
struct DefaultNode *n;
letter=IMsg->Code;
if(LG_GadForKey(GadControl,letter,&gadid,&code))
{
if(code&1) dirchange=-1;
switch(gadid)
{
case GD_LIST:
gadid=GD_NAME;
case GD_NAME:
case GD_WIDTH:
case GD_HEIGHT:
case GD_LOCKEDPENS:
case GD_PUBNAME:
case GD_HOTKEYSTR:
case GD_PENVAL:
// case GD_BACKDROPFILENAME:
ActivateStrGad=gadid;
break;
case GD_TYPE:
CurrentList_2+=dirchange;
GD_Type(CurrentList_2);
break;
case GD_NEW:
GD_New();
break;
case GD_SAVE:
GD_Save();
break;
case GD_USE:
GD_Use();
break;
case GD_CANCEL:
GD_Cancel();
break;
case GD_FE_CANCEL:
GD_FE_Cancel();
break;
case GD_FE_NEVER:
GD_FE_Never();
break;
case GD_FE_USEDELETE:
GD_FE_UseDelete();
break;
case GD_FE_SAVEUSE:
GD_FE_SaveUse();
break;
}
if(n=GetActiveNode())
switch(gadid)
{
case GD_SELECT_NAME:
GD_SelectName(n);
break;
case GD_MODESEL:
GD_ModeSel(n,dirchange,TRUE);
break;
case GD_SELMODE:
GD_SelMode(n);
break;
case GD_OVERSCAN:
GD_Overscan(n,dirchange,TRUE);
break;
case GD_REMOVE:
GD_Remove(n);
break;
case GD_PENLIST:
GD_PenList(n,dirchange,TRUE);
break;
case GD_RESETPENS:
GD_ResetPens(n);
break;
case GD_PICKFONT:
GD_PickFont(n);
break;
case GD_INTERLEAVE:
GD_Interleave(n,0,TRUE);
break;
case GD_BEHIND:
GD_Behind(n,0,TRUE);
break;
case GD_BLANK_BORDER:
GD_Blank_Border(n,0,TRUE);
break;
case GD_LOOK3D:
GD_Look3D(n,0,TRUE);
break;
case GD_AUTOSCROLL:
GD_AutoScroll(n,0,TRUE);
break;
case GD_3D_DEFAULT:
GD_3D_Default(n,0,TRUE);
break;
case GD_CENTER:
GD_Center(n,dirchange,TRUE);
break;
case GD_FASPECT:
GD_FAspect(n,0,TRUE);
break;
case GD_SFONT:
GD_SFont(n,dirchange,TRUE);
break;
case GD_PUBOPT:
GD_PubOpt(n,0,TRUE);
break;
case GD_DODEPTH:
GD_DoDepth(n,0,TRUE);
break;
case GD_SHAREPENS:
GD_SharePens(n,0,TRUE);
break;
case GD_HOTKEYOPT:
GD_HotKeyOpt(n,0,TRUE);
break;
case GD_PALETTE:
GD_Palette(n,0,TRUE);
break;
case GD_EDITPALETTE:
GD_EditPalette(n);
break;
case GD_MOVE:
GD_Move(dirchange,TRUE);
break;
case GD_DEPTH:
GD_Depth(n,dirchange,TRUE);
break;
case GD_FORCE_PLANAR:
GD_Force_Planar(n,0,TRUE);
break;
case GD_BACKDROPOPT:
GD_BackdropOpt(n,dirchange,TRUE);
break;
case GD_BACKDROPPICK:
GD_BackdropPick(n);
break;
case GD_BACKDROPCENTER:
GD_BackdropCenter(n,0,TRUE);
break;
case GD_BACKDROPCOLOR:
GD_BackdropColor(n,TRUE);
break;
}
}
}
void process_mousemoves(struct IntuiMessage *imsg)
{
struct Gadget *gad;
struct DefaultNode *n;
UWORD code,id;
code=imsg->Code;
gad=(struct Gadget*)imsg->IAddress;
id=gad->GadgetID;
if(n=GetActiveNode())
{
switch(id)
{
case GD_MOVE:
GD_Move(code,FALSE);
break;
case GD_DEPTH:
GD_Depth(n,code,FALSE);
break;
} /* End Switch */
}
}
void process_menus(struct IntuiMessage *imsg)
{
UWORD menunumber,ns;
ULONG menuid;
struct MenuItem *mi;
menunumber=imsg->Code;
mi=ItemAddress(MenuStrip,menunumber);
if(mi)
do
{
menuid=(ULONG)(GTMENUITEM_USERDATA(mi));
switch(menuid)
{
case M_OPEN:
if(SelectFile(MiscText[LOAD_MP_PREFS],FALSE) )
{
ObtainSemaphore(&MPSem->NodeSem);
LG_SetGadgetAttrs(GadControl,GD_LIST,
GTLV_Labels,~0,TAG_DONE);
FreeAllDefLists(MPSem->PromotionList);
ReleaseSemaphore(&MPSem->NodeSem);
PrefLoadFile(filename);
LVActive=0;
UpdateGadgets();
}
break;
/*
case M_SAVE:
ObtainSemaphore(&MPSem->NodeSem);
PrefSaveFile(EnvArcFile);
PrefSaveFile(EnvFile);
ReleaseSemaphore(&MPSem->NodeSem);
break;
*/
case M_SAVEAS:
if(SelectFile(MiscText[SAVE_MP_PREFS],TRUE) )
{
PrefSaveFile(filename);
}
break;
case M_IMPORT:
if(SelectFile(GetString(MSG_REQ_IMPORT_MP_PREFS),FALSE) )
{
LG_SetGadgetAttrs(GadControl,GD_LIST,
GTLV_Labels,~0,TAG_DONE);
ImportFile(filename);
UpdateGadgets();
}
break;
case M_ABOUT:
{
EZReq(Win,0,ModePro,AboutText,MiscText[OK],(ULONG)GetString(MSG_ABOUT_TRANSLATOR),
(ULONG)GetString(MSG_ABOUT_FORINFO));
}
break;
case M_HIDE:
ClosePrefs=TRUE;
//PrefSaveFile(EnvFile);
break;
case M_LASTSAVED:
ObtainSemaphore(&MPSem->NodeSem);
LG_SetGadgetAttrs(GadControl,GD_LIST,
GTLV_Labels,~0,TAG_DONE);
FreeAllDefLists(MPSem->PromotionList);
ReleaseSemaphore(&MPSem->NodeSem);
PrefLoadFile(EnvArcFile);
NodeCnt=CountNodes(&MPSem->PromotionList[CurrentList]);
LVActive=min(NodeCnt-1,LVActive);
UpdateGadgets();
break;
case M_RESTORE:
ObtainSemaphore(&MPSem->NodeSem);
LG_SetGadgetAttrs(GadControl,GD_LIST,
GTLV_Labels,~0,TAG_DONE);
FreeAllDefLists(MPSem->PromotionList);
ReleaseSemaphore(&MPSem->NodeSem);
PrefLoadFile(EnvFile);
NodeCnt=CountNodes(&MPSem->PromotionList[CurrentList]);
LVActive=min(NodeCnt-1,LVActive);
UpdateGadgets();
break;
case M_QUIT:
SendDaemonMsg(MP_QUIT,0,0);
break;
case M_ENABLED:// (4.62.1)
MPSem->Enabled=(mi->Flags & CHECKED ? 1:0);// (4.62.1)
//ActivateCxObj(Broker,MPSem->Enabled);
break;
case M_ENABLENL:
MPSem->EnabledNLM=(mi->Flags & CHECKED ? 1:0);
break;
case M_SET_UNKNOWN:
MPSem->CatchScreens=(mi->Flags & CHECKED ? 1:0);
break;
case M_SET_UNKNOWN_PUB:
MPSem->CatchPubScreens=(mi->Flags & CHECKED ? 1:0);
break;
case M_SET_CENTER_H:
MPSem->CenterAll=(MPSem->CenterAll & ~1) | (mi->Flags & CHECKED ? 1:0);
break;
case M_SET_CENTER_V:
MPSem->CenterAll=(MPSem->CenterAll & ~2) | (mi->Flags & CHECKED ? 2:0);
break;
case M_COPY_TO_SCR:
case M_COPY_TO_PRG:
case M_COPY_TO_SMODE:
case M_COPY_TO_PUB:
{
struct DefaultNode *dnode;
if(dnode=DupDNode(GetActiveNode()))
{
switch(menuid)
{
case M_COPY_TO_SCR:
dnode->Type=PL_SCREENNAMES;
break;
case M_COPY_TO_PRG:
dnode->Type=PL_PROGRAMNAMES;
break;
case M_COPY_TO_PUB:
dnode->Type=PL_PUBLICSCREENS;
break;
case M_COPY_TO_SMODE:
dnode->Type=PL_SCREENMODES;
break;
}
ObtainSemaphore(&MPSem->NodeSem);
LG_SetGadgetAttrs(GadControl,GD_LIST,
GTLV_Labels ,~0,
GTLV_Selected ,0,
TAG_DONE);
AddHead(&MPSem->PromotionList[dnode->Type],(struct Node *)dnode);
ReleaseSemaphore(&MPSem->NodeSem);
GD_Type(ListToCyc[dnode->Type]);
}
}
break;
case M_SORT:
{
struct Node *node;
struct List slist;
NewList(&slist);
ObtainSemaphore(&MPSem->NodeSem);
LG_SetGadgetAttrs(GadControl,GD_LIST,
GTLV_Labels ,~0,
GTLV_Selected ,0,
TAG_DONE);
while(node=RemHead(&MPSem->PromotionList[CurrentList]))
{
AddHead(&slist,node);
}
while(node=RemHead(&slist))
{
EnqueueName(&MPSem->PromotionList[CurrentList],node);
}
LVActive=0;
ReleaseSemaphore(&MPSem->NodeSem);
UpdateGadgets();
}
break;
}
ns=mi->NextSelect;
mi=ItemAddress(MenuStrip,mi->NextSelect);
}while(ns!= MENUNULL && mi);
}